<?php

/**
 * Description of emailTemplateGetAction
\* www.teuker.nl - mail@teuker.nl
 * 
 * @author francisc
 */

class emailTemplateGetAction extends sfAction {

    public function execute($request) {
        $category = SqlEngine::getTemplateCategory(array('name' => $request->getParameter('category')));
        $template = SqlEngine::getTemplates(array('category_id' => $category[0]['template_category_id']));

        if (empty($template))
            return $this->renderText(json_encode(array('body' => '', 'subject' => '')));
        
        return $this->renderText(json_encode($template[0]));
    }
}
